<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.0.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/img/favicon.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/img/favicon.ico">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('https://cxyzjp.gitee.io').hostname,
    root: '/',
    scheme: 'Pisces',
    version: '7.6.0',
    exturl: true,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":true},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":true},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: true,
    lazyload: true,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"preload":true},
    path: 'search.json',
    motion: {"enable":false}
  };
</script>

  <meta name="description" content="macOS没有提供包管理器，市面上最好的解决方案就是 Homebrew官网：https:&#x2F;&#x2F;brew.sh&#x2F;index_zh-cn">
<meta name="keywords" content="mac">
<meta property="og:type" content="article">
<meta property="og:title" content="Homebrew">
<meta property="og:url" content="https:&#x2F;&#x2F;cxyzjp.gitee.io&#x2F;mac&#x2F;Homebrew&#x2F;index.html">
<meta property="og:site_name" content="程序员的日常">
<meta property="og:description" content="macOS没有提供包管理器，市面上最好的解决方案就是 Homebrew官网：https:&#x2F;&#x2F;brew.sh&#x2F;index_zh-cn">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2020-02-18T16:27:27.021Z">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://cxyzjp.gitee.io/mac/Homebrew/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>Homebrew | 程序员的日常</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">程序员的日常</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <h1 class="site-subtitle" itemprop="description">自强不息</h1>
      
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档<span class="badge">5</span></a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签<span class="badge">6</span></a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocorrect="off" autocapitalize="none"
           placeholder="搜索..." spellcheck="false"
           type="text" id="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result"></div>

</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://cxyzjp.gitee.io/mac/Homebrew/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/img/avatar.jpg">
      <meta itemprop="name" content="CXYZJP">
      <meta itemprop="description" content="记录生活中的点点滴滴">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="程序员的日常">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          Homebrew
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-02-18 23:46:29" itemprop="dateCreated datePublished" datetime="2020-02-18T23:46:29+08:00">2020-02-18</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-02-19 00:27:27" itemprop="dateModified" datetime="2020-02-19T00:27:27+08:00">2020-02-19</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>macOS没有提供包管理器，市面上最好的解决方案就是 Homebrew<br>官网：<span class="exturl" data-url="aHR0cHM6Ly9icmV3LnNoL2luZGV4X3poLWNu" title="https://brew.sh/index_zh-cn">https://brew.sh/index_zh-cn<i class="fa fa-external-link"></i></span></p>
<a id="more"></a>

<h1 id="常用命令"><a href="#常用命令" class="headerlink" title="常用命令"></a>常用命令</h1><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">$ brew --help        #简洁命令帮助</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ man brew           #完整命令帮助</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew install git   #安装软件包(这里是示例安装的Git版本控制)</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew uninstall git #卸载软件包</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew search git    #搜索软件包</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew list          #显示已经安装的所有软件包</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew update        #同步远程最新更新情况，对本机已经安装并有更新的软件用*标明</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew outdated      #查看已安装的哪些软件包需要更新</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew upgrade git   #更新单个软件包</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew upgrade   	 #升级所有已过时的软件，即列出的以过时软件</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew pin git       #禁止指定软件升级</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew unpin git     #解锁禁止升级</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew info git      #查看软件包信息</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew home git      #访问软件包官方站</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew cleanup       #清理所有已安装软件包的历史老版本</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew cleanup git   #清理单个已安装软件包的历史版本</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew tap           #可以为brew的软件的 跟踪,更新,安装添加更多的的tap formulae</span></pre></td></tr><tr><td class="code"><pre><span class="line">$ brew doctor        #检测Homebrew</span></pre></td></tr></table></figure>

<h1 id="重置Homebrew默认源"><a href="#重置Homebrew默认源" class="headerlink" title="重置Homebrew默认源"></a>重置Homebrew默认源</h1><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"># 替换 Homebrew</span></pre></td></tr><tr><td class="code"><pre><span class="line">git -C &quot;$(brew --repo)&quot; remote set-url origin https:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;brew.git</span></pre></td></tr><tr><td class="code"><pre><span class="line"></span></pre></td></tr><tr><td class="code"><pre><span class="line"># 替换 Homebrew Core</span></pre></td></tr><tr><td class="code"><pre><span class="line">git -C &quot;$(brew --repo homebrew&#x2F;core)&quot; remote set-url origin https:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;homebrew-core.git</span></pre></td></tr><tr><td class="code"><pre><span class="line"></span></pre></td></tr><tr><td class="code"><pre><span class="line"># 替换 Homebrew Cask</span></pre></td></tr><tr><td class="code"><pre><span class="line">git -C &quot;$(brew --repo homebrew&#x2F;cask)&quot; remote set-url origin https:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;homebrew-cask.git</span></pre></td></tr><tr><td class="code"><pre><span class="line"></span></pre></td></tr><tr><td class="code"><pre><span class="line"># 替换 Homebrew-bottles</span></pre></td></tr><tr><td class="code"><pre><span class="line"># 对于 bash 用户：</span></pre></td></tr><tr><td class="code"><pre><span class="line">echo &#39;export HOMEBREW_BOTTLE_DOMAIN&#x3D;https:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;homebrew-bottles&#39; &gt;&gt; ~&#x2F;.bash_profile</span></pre></td></tr><tr><td class="code"><pre><span class="line">source ~&#x2F;.bash_profile</span></pre></td></tr><tr><td class="code"><pre><span class="line"># 对于 zsh 用户：</span></pre></td></tr><tr><td class="code"><pre><span class="line">echo &#39;export HOMEBREW_BOTTLE_DOMAIN&#x3D;https:&#x2F;&#x2F;mirrors.ustc.edu.cn&#x2F;homebrew-bottles&#39; &gt;&gt; ~&#x2F;.zshrc</span></pre></td></tr><tr><td class="code"><pre><span class="line">source ~&#x2F;.zshrc</span></pre></td></tr></table></figure>

<h1 id="名词解释"><a href="#名词解释" class="headerlink" title="名词解释"></a>名词解释</h1><table>
<thead>
<tr>
<th>英文</th>
<th>直译</th>
<th>实际含义</th>
</tr>
</thead>
<tbody><tr>
<td>formula(e)</td>
<td>公式</td>
<td>安装包的描述文件，formulae 为复数</td>
</tr>
<tr>
<td>cellar</td>
<td>地窖</td>
<td>安装好后所在的目录</td>
</tr>
<tr>
<td>keg</td>
<td>小桶</td>
<td>具体某个包所在的目录，keg 是 cellar 的子目录</td>
</tr>
<tr>
<td>bottle</td>
<td>瓶子</td>
<td>预先编译好的包，不需要现场下载编译源码，速度会快很多；官方库中的包大多都是通过 bottle 方式安装</td>
</tr>
<tr>
<td>tap</td>
<td>(插入) 水龙头</td>
<td>下载启用某个源</td>
</tr>
<tr>
<td>cask</td>
<td>木桶</td>
<td>安装 macOS native 应用的扩展</td>
</tr>
<tr>
<td>bundle</td>
<td>捆</td>
<td>描述 Homebrew 依赖的扩展</td>
</tr>
</tbody></table>
<h1 id="Homebrew-进阶用法"><a href="#Homebrew-进阶用法" class="headerlink" title="Homebrew 进阶用法"></a>Homebrew 进阶用法</h1><p>Homebrew 虽为解决控制台程序而生，但它完全有能力（Cask）安装任何桌面软件。它还支持丰富的分类目软件库或第三方库。</p>
<p>除此之外，它还有一个打包安装或备份工具，可以把已安装的软件输出成 Brewfile。迁移到新电脑时，只要根据 Brewfile 运行 Homebrew bundle，就可以一键安装全部控制台、桌面和来自 Mac App Store 的程序（Mac App Store 上的软件通过 <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL21hcy1jbGkvbWFz" title="https://github.com/mas-cli/mas">mas<i class="fa fa-external-link"></i></span> 支持）。</p>
<h3 id="Tap"><a href="#Tap" class="headerlink" title="Tap"></a>Tap</h3><p>Tap 在 Homebrew 中我理解是个动词，指的是启用某个源。实际看了下发现，homebrew-services 和 homebrew-bundle 也已 tap 形式存在，因此可以认为 tap 实际指的应该是扩展（extension）。</p>
<p>Homebrew 默认情况下会自带：</p>
<ul>
<li>homebrew/core</li>
<li>homebrew/cask</li>
<li>homebrew/services</li>
<li>homebrew/bundle</li>
</ul>
<p>后两者并没有任何公式配方，而只是扩展程序。</p>
<p>除此之外的源，需要通过 <code>brew tap</code> 来启用。如：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew tap heroku&#x2F;brew</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew install heroku</span></pre></td></tr></table></figure>

<h3 id="Services"><a href="#Services" class="headerlink" title="Services"></a>Services</h3><p><span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL0hvbWVicmV3L2hvbWVicmV3LXNlcnZpY2Vz" title="https://github.com/Homebrew/homebrew-services">Homebrew-services<i class="fa fa-external-link"></i></span> 是 Homebrew 的后台服务程序扩展，它基于 macOS 的 <code>launchctl</code>。后台服务类程序的安装依旧使用 Homebrew，在管理时可以使用 Homebrew-services 进行启动、重启和停止等操作。</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew install mysql</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew services start mysql</span></pre></td></tr></table></figure>

<h3 id="Cask"><a href="#Cask" class="headerlink" title="Cask"></a>Cask</h3><p><span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL0hvbWVicmV3L2hvbWVicmV3LWNhc2s=" title="https://github.com/Homebrew/homebrew-cask">Homebrew-cask<i class="fa fa-external-link"></i></span> 是 Homebrew 的 macOS Native 应用扩展，通过 cask 可以安装各类应用程序。</p>
<p>搜索 Cask 的方法和搜索普通包一样，但安装时需要加上 cask 指令：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew search google-chrome</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew cask install google-chrome</span></pre></td></tr></table></figure>

<blockquote>
<p>cask-versions</p>
</blockquote>
<p>Homebrew Cask 和 Homebrew 一样，默认库只维护最新版本，但有的时候我们还是需要用旧版的（比如：我只有 Dash 3 的 License，所以需要用 Dash 3 而不是最新的 Dash 4），那就可能需要使用 cask-versions。</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew tap homebrew&#x2F;cask-versions</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew cask install dash3</span></pre></td></tr></table></figure>

<blockquote>
<p>cask-fonts</p>
</blockquote>
<p>Homebrew 官方的字体源，比如 Mozilla 的开源字体 Fira Code：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew tap homebrew&#x2F;cask-fonts</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew cask install font-fira-code</span></pre></td></tr></table></figure>

<h3 id="Bundle"><a href="#Bundle" class="headerlink" title="Bundle"></a>Bundle</h3><p>Homebrew 不仅仅是一个包管理器，还具有软件依赖管理能力。通过 <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL0hvbWVicmV3L2hvbWVicmV3LWJ1bmRsZQ==" title="https://github.com/Homebrew/homebrew-bundle">Homebrew Bundle<i class="fa fa-external-link"></i></span> 可以帮你解决所有软件依赖，包括官方和第三方的 formula 以及 cask，甚至还包括 Mac App Store（简称 mas）中的应用。</p>
<p>Homebrew 默认就安装了 Homebrew Bundle。</p>
<p>我们只需要一个 <code>Brewfile</code>，就可以配置好所有需要的应用。熟悉 Ruby 的人应该不太需要解释，毕竟 Ruby 自己就有 Bundler 这套东西，Brewfile 和 Gemfile 属于对应关系。</p>
<p>如果你的安装列表已经足够 “干净”，那么可以执行 <code>brew bundle dump</code> 来生成现有依赖，输出到 <code>Brewfile</code>：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew bundle dump</span></pre></td></tr><tr><td class="code"><pre><span class="line">cat Brewfile</span></pre></td></tr><tr><td class="code"><pre><span class="line"></span></pre></td></tr><tr><td class="code"><pre><span class="line">brew &quot;git&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew &quot;wget&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew &quot;mas&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew &quot;p7zip&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">...</span></pre></td></tr></table></figure>

<p>如果想自己写也比较容易，<code>Brewfile</code> 是一种简单的 Ruby DSL，写起来比大部分配置文件都简单。只需要掌握一些常用到的命令，主要有 <code>brew</code>, <code>tap</code>, <code>cask</code> 和 <code>mas</code>。</p>
<p>这四条命令分别对应：</p>
<ul>
<li>brew install</li>
<li>brew tap</li>
<li>brew cask install</li>
<li>mas install</li>
</ul>
<blockquote>
<p>注：Homebrew 虽然好用，但 Homebrew 并不能管理 MAS「Mac App Store」上的应用软件，<span class="exturl" data-url="aHR0cHM6Ly93d3cuaGktbGludXguY29tL3Bvc3RzLzE4MjAyLmh0bWw=" title="https://www.hi-linux.com/posts/18202.html">在终端上轻松管理「Mac App Store」中应用的神器 mas-cli<i class="fa fa-external-link"></i></span></p>
</blockquote>
<p>命令行类应用：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew &quot;git&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew &quot;wget&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew &quot;vim&quot;</span></pre></td></tr></table></figure>

<p>非命令行类：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">cask &quot;google-chrome&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">cask &quot;alfred&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">cask &quot;visual-studio-code&quot;</span></pre></td></tr></table></figure>

<p>非官方 Formula 应用：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">tap  &quot;homebrew&#x2F;cask-versions&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew &quot;dash3&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">tap  &quot;homebrew&#x2F;cask-fonts&quot;</span></pre></td></tr><tr><td class="code"><pre><span class="line">cask &quot;font-source-code-pro&quot;</span></pre></td></tr></table></figure>

<p>Mac App Store 上的应用：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">mas &quot;WeChat&quot;, id: 836500024</span></pre></td></tr></table></figure>

<p>因此，维护好 <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2NyaXNwZ20vZG90ZmlsZXMvYmxvYi9tYXN0ZXIvQnJld2ZpbGU=" title="https://github.com/crispgm/dotfiles/blob/master/Brewfile">Brewfile<i class="fa fa-external-link"></i></span> 就可以完美解决应用自动化安装，只需要运行：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew bundle</span></pre></td></tr></table></figure>

<h2 id="Homebrew-扩展用法"><a href="#Homebrew-扩展用法" class="headerlink" title="Homebrew 扩展用法"></a>Homebrew 扩展用法</h2><h3 id="提交-Formula"><a href="#提交-Formula" class="headerlink" title="提交 Formula"></a>提交 Formula</h3><p>创建并提交一个 Formula 比较容易，官方教程非常详细。这里，我就不做单独介绍了。</p>
<h3 id="自建-Tap"><a href="#自建-Tap" class="headerlink" title="自建 Tap"></a>自建 Tap</h3><p>Homebrew 除了各种官方维护的源外，还支持自建软件库。默认使用 GitHub，需要以 “homebrew-xxx” 格式命名 Repo。Formula 或 Cask 文件需要存放在 Formula 或 Casks 二级目录中。</p>
<p>比如，Heroku 的自建库在 GitHub 上是 <code>heroku/homebrew-brew</code>。通过 <code>brew tap heroku/brew</code> 就可以获取库里维护的包了。</p>
<h3 id="私有-Tap"><a href="#私有-Tap" class="headerlink" title="私有 Tap"></a>私有 Tap</h3><p>上面说到，Tap 默认维护在 GitHub，那么当我们想安装一些需要 <strong>保密</strong> 的软件时该怎么办呢？</p>
<p>答案是 Tap 支持指定 Git，因此也可以使用内网域名内的 Git：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">brew tap yourcompany&#x2F;brew git@git.yourcompany.com: yourcompany&#x2F;homebrew-brew.git</span></pre></td></tr><tr><td class="code"><pre><span class="line">brew install inhouse-app</span></pre></td></tr></table></figure>

<h2 id="Homebrew-Tips"><a href="#Homebrew-Tips" class="headerlink" title="Homebrew Tips"></a>Homebrew Tips</h2><h3 id="禁用自动升级"><a href="#禁用自动升级" class="headerlink" title="禁用自动升级"></a>禁用自动升级</h3><p>Homebrew 自动升级触发概率很高，由于网络等问题，检查更新会很久有时会比较烦。可以通过环境变量禁用自动升级：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">HOMEBREW_NO_AUTO_UPDATE&#x3D;1 brew info mysql</span></pre></td></tr></table></figure>

<h3 id="直接安装-Formula"><a href="#直接安装-Formula" class="headerlink" title="直接安装 Formula"></a>直接安装 Formula</h3><p>Homebrew 的安装指令并非只支持名字，也可以用文件安装包括网络文件和本地文件。</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line"># 本地 </span></pre></td></tr><tr><td class="code"><pre><span class="line">brew install blabla.rb</span></pre></td></tr><tr><td class="code"><pre><span class="line"># 远程 </span></pre></td></tr><tr><td class="code"><pre><span class="line">brew install https:&#x2F;&#x2F;blablablabla.com&#x2F;blabla.rb</span></pre></td></tr></table></figure>

<h2 id="安装旧版软件"><a href="#安装旧版软件" class="headerlink" title="安装旧版软件"></a>安装旧版软件</h2><p>Homebrew 默认情况下只支持最新版软件安装，有些重要的版本会单独存在。但想安装一些小版本就得自己 DIY 了。</p>
<p>我所知有两种方法：</p>
<ol>
<li>在 GitHub 找到 Formula 所在 Repo 中（默认为 <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL0hvbWVicmV3L2hvbWVicmV3LWNvcmUvYmxvYi9tYXN0ZXIvRm9ybXVsYS8=" title="https://github.com/Homebrew/homebrew-core/blob/master/Formula/">homebrew-core<i class="fa fa-external-link"></i></span>）的文件，把文件远程地址复制下来，用 <code>brew install</code> 安装。</li>
<li>进入 homebrew-core 在 macOS 本地的路径，默认为 <code>/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core</code>，<code>git checkout</code> 到所在 commit，再用 <code>brew pin</code> 锁定这个文件的更新，然后进行安装。</li>
</ol>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/mac/" rel="tag"># mac</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/distributed/distributed-lock/" rel="prev" title="分布式锁">
      <i class="fa fa-chevron-left"></i> 分布式锁
    </a></div>
      <div class="post-nav-item"></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#常用命令"><span class="nav-number">1.</span> <span class="nav-text">常用命令</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#重置Homebrew默认源"><span class="nav-number">2.</span> <span class="nav-text">重置Homebrew默认源</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#名词解释"><span class="nav-number">3.</span> <span class="nav-text">名词解释</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Homebrew-进阶用法"><span class="nav-number">4.</span> <span class="nav-text">Homebrew 进阶用法</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Tap"><span class="nav-number">4.0.1.</span> <span class="nav-text">Tap</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Services"><span class="nav-number">4.0.2.</span> <span class="nav-text">Services</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Cask"><span class="nav-number">4.0.3.</span> <span class="nav-text">Cask</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Bundle"><span class="nav-number">4.0.4.</span> <span class="nav-text">Bundle</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Homebrew-扩展用法"><span class="nav-number">4.1.</span> <span class="nav-text">Homebrew 扩展用法</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#提交-Formula"><span class="nav-number">4.1.1.</span> <span class="nav-text">提交 Formula</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#自建-Tap"><span class="nav-number">4.1.2.</span> <span class="nav-text">自建 Tap</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#私有-Tap"><span class="nav-number">4.1.3.</span> <span class="nav-text">私有 Tap</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Homebrew-Tips"><span class="nav-number">4.2.</span> <span class="nav-text">Homebrew Tips</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#禁用自动升级"><span class="nav-number">4.2.1.</span> <span class="nav-text">禁用自动升级</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#直接安装-Formula"><span class="nav-number">4.2.2.</span> <span class="nav-text">直接安装 Formula</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装旧版软件"><span class="nav-number">4.3.</span> <span class="nav-text">安装旧版软件</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="CXYZJP"
      src="/img/avatar.jpg">
  <p class="site-author-name" itemprop="name">CXYZJP</p>
  <div class="site-description" itemprop="description">记录生活中的点点滴滴</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">5</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">6</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2N4eXpqcA==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;cxyzjp"><i class="fa fa-fw fa-github"></i></span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOjMyODEwODIyM0BxcS5jb20=" title="E-Mail → mailto:328108223@qq.com"><i class="fa fa-fw fa-envelope"></i></span>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cDovL2N4eXpqcC5jbg==" title="http:&#x2F;&#x2F;cxyzjp.cn">个人主页</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9naXRlZS5jb20vY3h5empwL2N4eXpqcC9wYWdlcw==" title="https:&#x2F;&#x2F;gitee.com&#x2F;cxyzjp&#x2F;cxyzjp&#x2F;pages">Gitee Pages</span>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 2018 – 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">CXYZJP</span>
</div>
  <div class="powered-by">由 <span class="exturl theme-link" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> 强力驱动
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <span class="exturl theme-link" data-url="aHR0cHM6Ly9waXNjZXMudGhlbWUtbmV4dC5vcmc=">NexT.Pisces</span>
  </div>

        








        
      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/medium-zoom@1/dist/medium-zoom.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script>
<script src="/js/utils.js"></script>
<script src="/js/schemes/pisces.js"></script>
<script src="/js/next-boot.js"></script>



  




  <script src="/js/local-search.js"></script>













  

  

  

</body>
</html>
